package com.zem.imos.Entity;

public class RespEntity {
    private int code;
    private String msg;
    private Object data;



    public RespEntity(ERespCode respCode) {
        this.code = respCode.getCode();
        this.msg = respCode.getMsg();
    }

    public RespEntity(ERespCode respCode, Object data) {
        this(respCode);
        this.data = data;
    }

    public RespEntity(CRespCode respCode) {
        this.code = respCode.getCode();
        this.msg = respCode.getMsg();
    }

    public RespEntity(CRespCode respCode, Object data) {
        this(respCode);
        this.data = data;
    }



    public void setCode(int code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public Object getData() {
        return data;
    }


// 自定义responsecode
    public static class CRespCode {

        private int code;
        private String msg;

        public CRespCode(int code, String msg) {
            this.msg = msg;
            this.code = code;
        }

        public int getCode() {
            return code;
        }
        public String getMsg() {
            return msg;
        }
    }

    //  枚举类responsecode
    public enum ERespCode {
        SUCCESS(200,"连接成功"),
        FAIL(400,"连接失败"),
        WARN(-1,"警告"),
        AuthReject(405,"token验证失败，没有权限"),
        Illegal(500,"请求不合法，请检查参数"),
        ERROR(-2,"错误");

        private int code;
        private String msg;

        ERespCode(int code, String msg) {
            this.msg = msg;
            this.code = code;
        }

        public int getCode() {
            return code;
        }
        public String getMsg() {
            return msg;
        }
    }

}
